﻿Imports System.Data.SqlClient

Public Class clsHorarios
    Private cnConn As SqlConnection
    Private Command As SqlCommand
    Public Sub CONECTA_BD()
        cnConn = New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Command = New SqlCommand("REGISTRA_HORARIOS", cnConn)
        Command.CommandType = CommandType.StoredProcedure
        Command.CommandTimeout = 0


        Command.Parameters.Add(New SqlParameter("@USERID", SqlDbType.Int))
        Command.Parameters.Add(New SqlParameter("@FECHA", SqlDbType.DateTime))
        Command.Parameters.Add(New SqlParameter("@MINUTOS", SqlDbType.Int))
        Command.Parameters.Add(New SqlParameter("@HORAS", SqlDbType.Int))

        Try
            cnConn.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try
    End Sub
    Public Sub CONECTA_BD_AUSENTES()
        cnConn = New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Command = New SqlCommand("EMPLEADOS_AUSENTES", cnConn)
        Command.CommandType = CommandType.StoredProcedure
        Command.CommandTimeout = 0

        Command.Parameters.Add(New SqlParameter("@FECHA", SqlDbType.DateTime))
        Command.Parameters.Add(New SqlParameter("@CLAVE", SqlDbType.Int))
        
        Try
            cnConn.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try
    End Sub
    Public Sub VERIFICA_ASISTENCIA(ByVal CLAVE As Integer, ByVal FECHA As Date)
        Command.Parameters("@FECHA").Value = FECHA
        Command.Parameters("@CLAVE").Value = CLAVE
       
        Try
            Command.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
        End Try


    End Sub
    Public Sub REGISTRAR(ByVal USERID As Integer, ByVal FECHA As Date, ByVal MINUTOS As Integer, ByVal HORAS As Integer)
        Command.Parameters("@USERID").Value = USERID
        Command.Parameters("@FECHA").Value = FECHA
        Command.Parameters("@MINUTOS").Value = MINUTOS
        Command.Parameters("@HORAS").Value = HORAS

        Try
            Command.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")

        End Try


    End Sub
    Public Sub Cerrar_BD()
        If cnConn.State = ConnectionState.Open Then
            cnConn.Close()
        End If
    End Sub

End Class
